package com.csw.fish;

import java.awt.*;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2022/11/16 21:37
 */
public class MyFish {
    //图片
    Image img = GameUtils.MyFishimg_L;
    //坐标
    int x = 700;
    int y = 500;
    int width = 50;
    int height = 50;
    //移动速度
    int speed = 20;
    //等级
    int level = 1;

    public void paintSelf(Graphics g){
        logic();
        g.drawImage(img, x, y, width+GameUtils.score,height+GameUtils.score,null);
    }
    //获取自身矩形的方法
    public Rectangle getMyRec(){
        return new Rectangle(x, y, width, height);
    }
    //方向控制
    void logic(){
        if (GameUtils.UP){
            y-=speed;
        }
        if (GameUtils.DOWN){
            y+=speed;
        }
        if (GameUtils.LEFT){
            x-=speed;
            img=GameUtils.MyFishimg_L;
        }
        if (GameUtils.RIGHT){
            x+=speed;
            img=GameUtils.MyFishimg_R;
        }
    }

    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }
}
